import 'package:flutter/material.dart';
import 'package:flutter_aggregate/model/plant/constants.dart';
import 'package:flutter_svg/svg.dart';

class HeaderWithSearchBox extends StatelessWidget {
  const HeaderWithSearchBox({
    Key? key,
    required this.size,
  }) : super(key: key);

  final Size size;

  @override
  Widget build(BuildContext context) {
    double statusHeight = MediaQuery.of(context).padding.top;
    return Container(
      height: (size.height * 0.2) + statusHeight + palntKDefaultAppBarHeigth,
      margin: const EdgeInsets.only(
        bottom: palntKDefaultPadding * 2
      ),
      child: Stack(
        children: [
          Container(
            alignment: Alignment.bottomCenter,
            padding: const EdgeInsets.only(
              left: palntKDefaultPadding,
              right: palntKDefaultPadding,
              bottom: 36 + palntKDefaultPadding
            ),
            height: (size.height * 0.2 - 27) + statusHeight + palntKDefaultAppBarHeigth,
            decoration: const BoxDecoration(
              color: palntKPrimaryColor,
              borderRadius: BorderRadius.vertical(
                bottom: Radius.circular(36)
              )
            ),
            child: Row(
              children: [
                Text(
                  '您好 XJB',
                  style: Theme.of(context).textTheme.headline5!.copyWith(
                    color: Colors.white,
                    fontWeight: FontWeight.bold
                  ),
                ),
                const Spacer(),
                Image.asset('assets/plant/images/logo.png')
              ],
            ),
          ),
          Positioned(
            bottom: 0,
            left: 0,
            right: 0,
            child: Container(
              alignment: Alignment.center,
              margin: const EdgeInsets.symmetric(horizontal: palntKDefaultPadding),
              padding: const EdgeInsets.symmetric(horizontal: palntKDefaultPadding),
              height: 54,
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(20),
                boxShadow: [
                  BoxShadow(
                    offset: const Offset(0 ,10),
                    blurRadius: 50,
                    color: palntKPrimaryColor.withOpacity(0.23)
                  )
                ]
              ),
              child: Row(
                children: [
                  Expanded(child: TextField(
                    decoration: InputDecoration(
                      hintText: '搜索',
                      hintStyle: TextStyle(
                        color: palntKPrimaryColor.withOpacity(.5)
                      ),
                      enabledBorder: InputBorder.none,
                      focusedBorder: InputBorder.none
                    ),
                  )),
                  SvgPicture.asset('assets/plant/icons/search.svg')
                ],
              ),
            )              
          )
        ],
      ),
    );
  }
} 